<include file="Public:top" />
<!--头部 end-->
<script type="text/javascript" src="__PUBLIC__/js/ajaxfileupload.js"></script>
 <include file="Public:menu" /> 
 <!--菜单 end-->
<form  id='crewForm' >
			<div class="form-group">
                    <div class="label"><label for="title">店面名称</label></div>
                    <div class="field">
                        <input type="text" class="input"  name="td_name" size="20" value="{$result.td_name}" placeholder="请填写宴会标题" data-validate="required:请填写宴会标题，建议在12字以内。" style="width:40%;" />
                    </div>
            </div>
            <div class="form-group">
                    <div class="label"><label for="title">排序</label></div>
                    <div class="field">
                        <input type="number" class="input"  name="sort" size="20" value="{$result.sort}" placeholder="请填写数字" style="width:20%;" />
                    </div>
            </div>

            <div class="form-group">
                    <div class="label"><label for="logo">头像图：</label></div>
                    <div class="field">
                        <a class="button input-file" href="javascript:void(0);">+ 浏览文件
                        	<input size="100" type="file" id="fileToUploade" name="upload"  data-validate="required:请选择上传头像图片,regexp#.+.(jpg|jpeg|png|gif)$:只能上传jpg|gif|png格式文件" /></a>
                    </div>
                    
                </div>
			
             <div class="form-group">
                <div class="label"><label for="logo">店面预览图：</label></div>
            
                <img src="{$result.td_head_img}" alt="" id="preview" width="200px" height="200px">

                <input type="hidden"  name="td_head_img" value="{$result.td_head_img}">
             </div>

			 <for start="0" end="3"> 

             <div class="form-group">
                    <div class="label"><label for="logo">产品展示图：</label></div>
                    <div class="field">
                        <a class="button input-file" href="javascript:void(0);">+ 浏览文件
                        	<input size="100" type="file" id="fileToUpload{$i}" name="upload" class='upload'  data-validate="required:请选择上传文件,regexp#.+.(jpg|jpeg|png|gif)$:只能上传jpg|gif|png格式文件" /></a>
                    </div>
                    
                </div>
		
             <div class="form-group">
                <div class="label"><label for="logo">产品预览图：</label></div>

                <img src="{$result['td_intro_img'][$i]['img']}" alt="" width="320px" height="200px">

                <input type="hidden"  name="td_intro_img[{$i}][img]" value="{$result['td_intro_img'][$i]['img']}">
             </div>

			 </for> 
              <div class="form-group">
                    <div class="label"><label for="readme">简洁介绍</label></div>
                    <div class="field">
                        <textarea class="input" name="td_text" rows="5" cols="50" placeholder="请填写简介说明" data-validate="required:请填写简介说明">{$result.td_text}</textarea>
                    </div>
                </div>

             <div class="form-group">
                                <script src="__PUBLIC__/ue/ueditor.config.js"></script>
                                <script src="__PUBLIC__/ue/ueditor.all.min.js"></script>
                            <div class="label"><label for="readme">店面详情</label></div>
                            <div class="field">
                                <textarea  name="td_content" id="editor" rows="5" cols="50" placeholder="请填写维护说明" data-validate="required:请填写维护说明">{$result.td_content}</textarea>
                                 <script>
                                         var ue = UE.getEditor("editor",{
                                            toolbars: [
                                                ['fullscreen', 'source',  'redo','bold','italic','|','customstyle','backcolor','removeformat', 'selectall','cleardoc', '|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','fontfamily','fontsize','paragraph','forecolor',]
                                            ],
                                            autoHeightEnabled: true,
                                            autoFloatEnabled: true,
                                            initialFrameHeight:420
                                        });
                                 </script>
                              </div>
                            </div>
                            <input type="hidden" name="td_id" value="{$result.td_id}">
       <div class="form-button" align="center"><button class="button bg-main" id="sure" type="submit">提交</button></div>

</form>


  <include file="Public:box" /> 
 <!--底部 end-->
 <script>
    
    $('.tpl_img').click(function(){

        $('input:radio').removeAttr('checked');

        $(this).next().next('input').prop('checked','checked');

    })
    

    //异步表单提交
        $('#sure').click(function(){

            $.post('/Console/feast/doUpdate',$('form').serialize(),function(data){

                if ( data.status )
                {
                    layer.alert(data.info, 1);

                    //刷新当前页
                    location.href = "/Console/feast";
                }
                else
                {

                    layer.alert(data.info);

                }

            },'json');

            return false;

        })

      //异步图片上传
        $('body').on('change','#fileToUploade',function(){

            $.ajaxFileUpload
            (
                {
                    url:'/console/feast/uploadImg1',
                    secureuri:false,
                    fileElementId:'fileToUploade',
                    dataType: 'json',
                    success: function (data)
                    {
                        //成功
                        if ( data.status )
                        {
                            $('#preview').attr('src', data.path);
                            $("[name='td_head_img']").val(data.path);
                        }
                        //失败
                        else
                        {
                            layer.alert(data.info);
                        }

                    }
                }
            )


        })

     //异步图片上传
        $('body').on('change','.upload',function(){

            var _this = $(this);

            var id = _this.attr('id');

            var div = _this.parent().parent().parent().next('div').children('img');

            var input = _this.parent().parent().parent().next('div').children('input');

            $.ajaxFileUpload
            (
                {
                    url:'/Console/feast/uploadImg',
                    secureuri:false,
                    fileElementId:id,
                    dataType: 'json',
                    success: function (data)
                    {
                        //成功
                        if ( data.status )
                        {
                            div.attr('src', data.path);
                            input.attr('value',data.path);
                        }
                        //失败
                        else
                        {
                            layer.alert(data.info);
                        }

                    }
                }
            )


        })
  

</script>